// OgreColourFadingAffector.h
// 

#ifndef __ColourFadingAffector_H__
#define __ColourFadingAffector_H__

#include "OgreParticleFXPrerequisites.h"
#include "OgreParticleAffector.h"
#include "OgreStringInterface.h"
#include "OgreColourValue.h"

namespace Ogre {

	class _OgreParticleFXExport ColourFadingAffector : public ParticleAffector
	{
	public:

		enum { MAX_STAGES = 6 };

		/** Command object for colour adjust (see ParamCommand).*/
		class CmdColourAdjust : public ParamCommand
		{
		public:
			size_t mIndex;

		public:
			String doGet(const void* target) const;
			void doSet(void* target, const String& val);
		};

		/** Command object for time adjust (see ParamCommand).*/
		class CmdTimeAdjust : public ParamCommand
		{
		public:
			size_t mIndex;

		public:
			String doGet(const void* target) const;
			void doSet(void* target, const String& val);
		};

		/** Command object for Opacity (see ParamCommand).*/
		class CmdOpacity : public ParamCommand
		{
		public:
			String doGet(const void* target) const;
			void doSet(void* target, const String& val);
		};

		/** Command object for FadeInTime (see ParamCommand).*/
		class CmdFadeInTime : public ParamCommand
		{
		public:
			String doGet(const void* target) const;
			void doSet(void* target, const String& val);
		};

		/** Command object for FadeOutTime (see ParamCommand).*/
		class CmdFadeOutTime : public ParamCommand
		{
		public:
			String doGet(const void* target) const;
			void doSet(void* target, const String& val);
		};

		/** Command object for RepeatTimes (see ParamCommand).*/
		class CmdRepeatTimes : public ParamCommand
		{
		public:
			String doGet(const void* target) const;
			void doSet(void* target, const String& val);
		};

	public:

		/** Default constructor. */
		ColourFadingAffector(ParticleSystem* psys);

		/** See ParticleAffector. */
		void _initParticle(Particle* pParticle);

		/** See ParticleAffector. */
		void _affectParticles(ParticleSystem* pSystem, Real timeElapsed);

	public:

		void setColourAdjust(size_t index, ColourValue colour);
		ColourValue getColourAdjust(size_t index) const;

		void setTimeAdjust(size_t index, Real time);
		Real getTimeAdjust(size_t index) const;

		void setOpacity(Real op);
		Real getOpacity(void) const;

		void setFadeInTime(Real fit);
		Real getFadeInTime(void) const;

		void setFadeOutTime(Real fot);
		Real getFadeOutTime(void) const;

		void setRepeatTimes(Real rt);
		Real getRepeatTimes(void) const;

	public:

		static CmdColourAdjust	msColourCmd[MAX_STAGES];
		static CmdTimeAdjust	msTimeCmd[MAX_STAGES];
		static CmdOpacity       msOpacityCmd;
		static CmdFadeInTime    msFadeInTimeCmd;
		static CmdFadeOutTime   msFadeOutTimeCmd;
		static CmdRepeatTimes   msRepeatTimesCmd;

	protected:

		ColourValue				mColourAdj[MAX_STAGES];
		Real					mTimeAdj[MAX_STAGES];
		Real                    mOpacity;
		Real                    mFadeInTime;
		Real                    mFadeOutTime;
		Real                    mRepeatTimes;

	};


}


#endif
